home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / iflib / mkdir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-04  |  448 b   |  24 lines

  1. #include <sys/types.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <sys/wait.h>
  5.  
  6. #define MKDIR "/bin/mkdir"
  7. #define DEVNULL "/dev/null"
  8.  
  9. int mkdir(dir)
  10. char *dir;
  11. {
  12.     int pid,rc,status;
  13.  
  14.     if ((pid=fork()) == 0)
  15.     {
  16.         freopen(DEVNULL,"w",stdout);
  17.         freopen(DEVNULL,"w",stderr);
  18.         rc=execl(MKDIR,MKDIR,dir,NULL);
  19.         return rc;
  20.     }
  21.     while (((rc=wait(&status)) == pid) || (rc == 0));
  22.     return ((status & 0xff) == 0) ? (status >> 8) : (status & 0xff);
  23. }
  24.